/**
 * Created by 王健 on 2019-12-10.
 */
$(function () {

    var html_data = {
        baseConfig: baseConfig,
        sessionid: '',
        sessionid_q: '',
        userinfo:{express_id:-1, express_no:"", express_name:""},
        tongji:{},
        default_address: null,
        goods_order_id: parseInt(GetQueryString("goods_order_id")),
        exprress_list: []

    };
    var app = new Vue({
        el: '#user_info',
        data: html_data,
        methods: {
            price_filter: price_filter,

            scan_qr:function(){
                ttjd.scan_qrcode(function (data) {
                    html_data.userinfo.express_no = data;
                },function (data) {

                });
            },
            save_alipay:function(){
                var parm = {
                    goods_order_id: html_data.goods_order_id,
                    express_id: html_data.userinfo.express_id,
                    express_no: html_data.userinfo.express_no,
                    express_name: html_data.userinfo.express_name
                };
                var b = true;
                if (parseInt(parm.express_id) == 0) {
                    if (parm.express_name == '') {
                        setTimeout(function () {
                            Magiclamp.mcAlert("提示", "请填写物流名称");
                        }, 100);

                        b = false;
                    }
                }else{
                    _(html_data.exprress_list).each(function (item) {
                        if(parm.express_id==item.id){
                            parm['express_name'] = item.name;
                        }
                    });
                }
                if (!parm.express_no) {
                    setTimeout(function () {
                        Magiclamp.mcAlert("提示", "请填写快递单号");
                    }, 100);
                    b = false;
                }
                if (!b) {
                    return false;
                }
                api.lorder.add_goods_order_express(parm).then(function (data) {
                    baseConfig.page_back();
                }, function (data) {

                });

            },
            query_express_list: function () {
                api.lorder.query_express_list().then(function (data) {
                    var exprress_list = data.result.list;
                    exprress_list.push({id: 0, name: "其他"})
                    html_data.exprress_list = exprress_list;
                });
            },

            page_back: function () {
                baseConfig.page_back();
            }
        }
    });

    html_data.sessionid = GetQueryString('sessionid');
    if (html_data.sessionid) {
        html_data.sessionid_q = "sessionid=" + html_data.sessionid;
        client_storage('sessionid', html_data.sessionid);
    }


    app.query_express_list();

});
